<?php
require_once VDIR . '/framework/vendor/php-console/src/PhpConsole/__autoload.php';
require VDIR . '/env.php';

$params = require __DIR__ . '/params.php';
$config = [
    'id' => 'basic',
    'vendorPath' => VDIR . '/framework/vendor',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'modules' => [
    ],
    'components' => [
        'request' => [
            'enableCookieValidation' => false,
            'enableCsrfValidation' => false,
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => true,
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'BaseComponents\customLog\CustomFileLog',
                    'logFile' => '/home/wwwlogs/php/zb.ichengxi.cn/php.log',
                    'levels' => ['error', 'warning'],
                    'logVars' => [],
                ],
            ],
        ],
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME,
            'username' => DB_USER,
            'password' => DB_PWD,
            'charset' => 'utf8mb4',
        ],
        'redis' => [
            'class' => 'BaseComponents\base\RedisConn',
            'hostname' => REDIS_HOST,
            'port' => REDIS_PORT,
        ],
        'session' => [
            'class' => 'yii\redis\Session',
            'redis' => [
                'hostname' => REDIS_HOST,
                'port' => REDIS_PORT,
                'database' => 0,
            ],
        ],
        'curl' => [
            'class' => 'yii\curl\Curl',
        ],
    ],
    'params' => $params,
];

if (YII_ENV == 'dev') {
    // configuration adjustments for 'dev' environment
//    $config['bootstrap'][]      = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '192.168.*.*', '::1'], // 按需调整这里
    ];
}

return $config;
